home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 February
/
PCWorld_2000-02_cd.bin
/
Software
/
Servis
/
FFE
/
MOD.SWG
/
0051_ALM Aley's Module.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1997-05-08
|
6KB
|
128 lines
***********************************
*** ALM file format DOCUMENTATION ***
***********************************
ALM (Aley's Module) is the only MOD-like music format used on 8bit computers.
It is designed to be usable on Sam Coupe (CPU Z80 6MHz) and PC XT. That
computers nomally couldn't play MOD-like music. The ALM file format is very
simple and it have no special effects, so every computer can play the ALMs.
ALM file format and ALM Player routine was developed by Aley Keprt some years
ago. Now there is a complete documentation of that music format. (The
documentation was released never before!) The whole player routine is speed
optimized and is about 600 bytes long. The size optimized one is only 300
bytes long. So, this is really the shortest MOD-like music player. :-)
There are three versions of ALM. Version 1.1 have speed-info (like S3M),
version 1.0 uses only standart speed. Version 1.2 is the same as 1.1, but it
uses samples-with-header (see below).
offset length descrioption
===================================================
0 8 id-text "Aley Mod" - version 1.0
0 7 id-text "AleyMod" - version 1.1 & 1.2 (there is no space!)
7 1 speed in 1/100 sec. - version 1.1 & 1.2
To determine, which format version is that file, read byte 4. If there is char
" " (32dec), it is version 1.0. If there is char "M" (77dec), it is version
1.1 or 1.2. If the version is 1.0, the speed is always 12. If the version is
1.1 or 1.2, you should read the version from byte 7. (Read below about the
speed calcs.) Version 1.2 is full-compatible with version 1.1.
After this strange intro, both format versions are the same...
offset length descrioption
===================================================
8 1 length of song (number of positions)
9 1 restart position
10 128 order list (sequences 0-127)
And that's all. Really short file header, isn't it? After these 138 bytes,
there are patterns. Patterns are stored like STM (or MOD), but there isn't
effect! So, each <note> is only 2 bytes long.
first byte = note
second byte = sample
ad note: number 0 means "no note"
numbers 1-12 are octave 1 (1=c, 2=c#, 3=d, etc.)
numbers 13-24 are octave 2 (13=c, 14=c#, 15=d, etc.)
numbers 25-36 are octave 3
number 37 means "key off" (turns the channel off until next note)
Order of notes in the pattern:
ofs.0 row 0, chan 1, note
ofs.1 row 0, chan 1, sample
ofs.2 row 0, chan 2, note
ofs.3 row 0, chan 2, sample
...
ofs.511 row 63,chan 4, sample
As you can see, ALM has ALWAYS 4 channels and 64 rows in the pattern. You
can also see that patterns are stored like MOD or STM. The size of one pattern
is always 512 bytes. The patterns are never compressed.
Samples are stored in their own files. Their filename extensions are 1,2,3,
etc. There are none zeroes in the extensions. Here comes the example:
ALM filename: saysay.alm
sample names: saysay.1, saysay.2, saysay.5, etc.
Loader scans directory and loads all the numbers he found. There can be also
only some samples, e.g. 1,2,5,7,10. In this case, loader skips numbers
3,4,6,8,9.
Samples are stored as 8-bit mono UNSIGNED. The frequency for middle C (C-2) is
always standard 8363 Hz (like MOD). Each sapmlefile has this short header:
offset length descrioption
===================================================
0 1 zero (0) byte - identification byte!!!
1 2 begin of the loop (Intel word)
3 2 end of the loop (Intel word)
If there is no loop, both values equals to the sample length.
REMEBER! If the first byte isn't zero (0), there are no header!!! That means
you have to test the first byte of the sample, and if there isn't the zero,
it's sample without header. Samples without header cannot have a loop.
Some hints:
~~~~~~~~~~~
Sample volumes cannot be set because of slow CPU speed on that computers. The
volumes can be (and be sure they are) precalculated and whole tune has the same
volume for each sample. This can be done either in ALM editor or in MOD->ALM
converter.
The speed info in the offset 7 is in 1/100 of second. That means 12 is the
standard speed - the same speed as 6 in other formats. For speed optimization,
there aren't 100 ticks per second, but only (100/speed) ticks. Beacuse of none
effects in the ALM, one output buffer is not 1/50 sec., but much longer. If the
speed is 12, there are only about 8 ticks per second. This is really uncommon,
but is't very fast, because you don't spend much time updating tune. (It's
designed for that 8bit computer!)
Each sample can be up to 32768 bytes long (not 64k!). It's because of Sam
Coupe's segment limitations. You know Sam Coupe is an 8bit computer, so be
happy, that it allows you to use segmented memory addressing. 32k is not good,
but it really couldn't be better. There can be max. 30 samples in one tune, but
the real number is slower, depending of free memory.
Channels 1 and 3 are left, channels 2 and 4 are right. Yes, Sam Coupe's sound
chip really has 4 stereo channels. This is the standard LRLR (remember! MOD has
LRRL!!!).
If you use PC AT and have 1MB RAM, you'll have no problems with memory and
speed. The ALM player is fast enough to play 44kHz on PC AT 8MHz!!! On the Sam
Coupe, the rate is much lower, about 8kHz.
There are lots of MOD tunes converted into ALM. You may need'em if you are
going to add ALM support to your player. So, if it's true, contact the author.
-------------------------------------------------------------------------------
This document is provided "as is". But if you have any questions, you can
contact the author. Contact him also if you want to make a new ALM player. :-)
Internet e-mail: keprta@risc.upol.cz, keprta@infnw.upol.cz
Snail mail: Aley Keprt, Brezecka 504/30A, Stepanov, 78313, Czech republic
-------------------------------------------------------------------------------
<you can print this doc using 64lines/page> signed: Aley [eili] Keprt